using System;
using System.Collections.Generic;
using System.Text;
using Pixysoft.Tools;
using Pixysoft.Weblications.Sango.Formular;
using Pixysoft.Framework.Verifications;
using Pixysoft.Framework.Noebe;
using Pixysoft.Weblications.Sango.Entities;
using Pixysoft.SQL;

namespace Pixysoft.Weblications.Sango.Environment
{
    public class WarOfficerHelper
    {
        private static List<War_Officer> orms = new List<War_Officer>();

        public static void initialize()
        {
            IEntityNoebeCommand command = SettingHelper.GetNoebe().EntityNoebeCommand;
            command.SQL = SqlCreator.SelectAll().From(Schemas.LOCAL.WAR_OFFICER).OrderBy(Schemas.LOCAL.WAR_OFFICER.POSITIONINDEX).GetSQL();
            orms = command.ExecuteReader<Entities.War_Officer>();

            LoggerHelper.Info("initialize War_Officer.countin{0}", orms.Count);
        }

        public static List<War_Officer> searchOfficers(Int64 stageserialcode)
        {
            List<War_Officer> officers = new List<War_Officer>();

            foreach (War_Officer orm in orms)
            {
                if (orm.Stageserialcode == stageserialcode)
                    officers.Add(orm);
            }

            return officers;
        }

        public static List<War_Officer> searchAll()
        {
            return orms;
        }
    }
}